package edu.buaa.act.model;

import com.graphhopper.util.*;

/**
 * Created by T7810 on 2017/4/22.
 */
public class GPSPoint extends GPXEntry
{
//    private static DistanceCalc distanceCalc = new DistancePlaneProjection();
//    public static double latitudeCenter = 0D/0;
//    public static double longitudeCenter = 0D/0;

    private int carID;
    private long carNo;
    private int timeSlot;
//    private double x = 0D/0;
//    private double y = 0D/0;

    public GPSPoint(long carNo, long timestamp, double longitude, double latitude, float speed, int angle)
    {
        super(latitude, longitude, timestamp);
        this.carNo = carNo;
        this.carID = -1;
    }

    public GPSPoint(int carID, long timestamp, double longitude, double latitude)
    {
        super(latitude, longitude, timestamp);
        this.carNo = -1;
        this.carID = carID;
    }

    public int getCarID()
    {
        return carID;
    }

    public void setCarID(int carID)
    {
        this.carID = carID;
    }

    public long getCarNo()
    {
        return carNo;
    }

    public void setCarNo(long carNo){
        this.carNo = carNo;
    }

    public long getTimestamp()
    {
        return this.getTime();
    }

    public int getTimeSlot()
    {
        return timeSlot;
    }

    public void setTimeSlot(int timeSlot)
    {
        this.timeSlot = timeSlot;
    }

    public double getLongitude()
    {
        return this.getLon();
    }

    public double getLatitude()
    {
        return this.getLat();
    }

//    public double getX() {
//        if(Double.isNaN(this.x)){
//            if(!Double.isNaN(latitudeCenter) && !Double.isNaN(longitudeCenter)){
//                this.x = distanceCalc.calcDist(this.getLat(), this.getLon(), latitudeCenter, longitudeCenter);
//            }else{
//                throw new RuntimeException("latitude/longitude center no set!");
//            }
//        }
//        return this.x;
//    }
//
//    public double getY() {
//        if(Double.isNaN(this.y)){
//            if(!Double.isNaN(latitudeCenter) && !Double.isNaN(longitudeCenter)){
//                this.y = distanceCalc.calcDist(this.getLat(), this.getLon(), latitudeCenter, longitudeCenter);
//            }else{
//                throw new RuntimeException("latitude/longitude center no set!");
//            }
//        }
//        return this.y;
//    }
//
//    private void latLon2XY(){
//        double dLat = Math.toRadians(toLat - fromLat);
//        double dLon = Math.toRadians(toLon - fromLon);
//        double tmp = Math.cos(Math.toRadians((fromLat + toLat) / 2.0D)) * dLon;
//        double normedDist = dLat * dLat + tmp * tmp;
//        return 6371000.0D * Math.sqrt(normedDist);
//    }

    public String toStringShort(char sep){
        return String.valueOf(carID) + sep +
                timeSlot + sep +
                getLat() + sep +
                getLon();
    }

    public String toString(){
        return toStringShort(' ');
    }

}
